﻿using UnityEngine;
using System.Collections;

namespace Battle
{
    public class BattleHeroItemGuide : MonoBehaviour
    {
        public BattleHeroItem heroItem;

        void Start()
        {
            heroItem = GetComponent<BattleHeroItem>();
            if (heroItem == null)
            {
                Destroy(this);
            }
        }

        public enum GuideType
        {
            None,
            NormalAttack,
            Ultimate
        }

        GuideType _currentGuideType = GuideType.None;
        public GuideType currentGuideType
        {
            get
            {
                return _currentGuideType;
            }
            set
            {
                _currentGuideType = value;
                if (_currentGuideType == GuideType.NormalAttack)
                {
                    ShowNormalAttackTip();
                }
                else if (_currentGuideType == GuideType.Ultimate)
                {
                    ShowUltimateAttackTip();
                }
                else
                {
                    HideTip();
                }
            }
        }

        void Update()
        {
            //if (currentGuideType == GuideType.Ultimate)
            //{
            //    if (!heroItem.owner.IsUltimateSkillCanCast4UI())
            //    {
            //        if (heroItem.owner.IsFirstSkillCanCast4UI()|| heroItem.owner.IsSecondSkillCanCast4UI())
            //        {
            //            currentGuideType = GuideType.NormalAttack;
            //        }
            //        else
            //        {
            //            currentGuideType = GuideType.None;
            //        }
            //    }
            //}
            //else if (currentGuideType == GuideType.NormalAttack)
            //{
            //    if (heroItem.owner.IsUltimateSkillCanCast4UI())
            //    {
            //        currentGuideType = GuideType.Ultimate;
            //    }
            //    else
            //    {
            //        if (!heroItem.owner.IsFirstSkillCanCast4UI() && !heroItem.owner.IsSecondSkillCanCast4UI())
            //        {
            //            currentGuideType = GuideType.None;
            //        }
            //    }
            //}
            //else if (currentGuideType == GuideType.None)
            //{
            //    if (heroItem.owner.IsUltimateSkillCanCast4UI())
            //    {
            //        currentGuideType = GuideType.Ultimate;
            //    }
            //    else
            //    {
            //        if (heroItem.owner.IsFirstSkillCanCast4UI() || heroItem.owner.IsSecondSkillCanCast4UI())
            //        {
            //            currentGuideType = GuideType.NormalAttack;
            //        }
            //    }

            //}

        }

        public void ShowNormalAttackTip()
        {
            BattleManager.Instance.battlePanel.guidePanel.GetComponent<View.GuideTipPanel>().ShowNormalAttackTip(this);

        }

        public void ShowUltimateAttackTip()
        {
            BattleManager.Instance.battlePanel.guidePanel.GetComponent<View.GuideTipPanel>().ShowUltimateAttackTip(this);

        }

        public void HideTip()
        {
            BattleManager.Instance.battlePanel.guidePanel.GetComponent<View.GuideTipPanel>().Hide();
        }

    }
}